//转化省标数据内容
var pageii = null;
var baseURL = "../../";
$(function () {
  selfAdaptionScreen();
    /*$('.auditIssues').click(function () {
        auditIssues()
    })
    $('.reviewAndRectify').click(function () {
        reviewAndRectify()
    })*/
    $('.dtTab li').click(function () {
        $(this).siblings().removeClass('selected')
        $(this).addClass('selected')
//        var val = $(this).attr("data-id")
//        var selectDateId = $(this).attr('id');
//        switch (selectDateId) {
//
//            //已审核
//            case 'audited' :
//                layer.msg("已审核"+val)
//                break
//            //未审核
//            case 'unaudited' :
//                layer.msg("未审核"+val)
//                break
//            //已整改
//            case 'haveChanged' :
//                layer.msg("已整改"+val)
//                break
//            //未整改
//            case 'noChanged' :
//                layer.msg("未整改"+val)
//                this.getQuestionDetail();
//                break
//            //全部
//            default:
//                layer.msg("全部"+val)
//        }
    });

})
//自适应屏幕分辨率
function selfAdaptionScreen(){
  var screenWidth = window.screen.width;
  if(screenWidth<=1366){
    $("#dcjlBody").css("zoom","0.62");
  }else if(screenWidth>1366 && screenWidth<=1440){
    $("#dcjlBody").css("zoom","0.64");
  }else if(screenWidth>1440 && screenWidth<=1600){
    $("#dcjlBody").css("zoom","0.72");
  }else if(screenWidth>1600 && screenWidth<=1680){
    $("#dcjlBody").css("zoom","0.78");
  }else if(screenWidth>1680 && screenWidth<=1768){
    $("#dcjlBody").css("zoom","0.82");
  }else{
    $("#dcjlBody").css("zoom","0.91");
  }
}
function auditIssues(id) {
    pageii = layer.open({
        title: "审核",
        type: 2,
        shadeClose: true,
        closeBtn:0,
        fixed: true,
        area: ["850px", "550px"],
        content: baseURL + '/business/record/auditIssues.html'
    });
}
function reviewAndRectify(id) {
    pageii = layer.open({
        title: "整改",
        type: 2,
        closeBtn:0,
        shadeClose: true,
        fixed: true,
        area: ["850px", "550px"],
        content: baseURL + '/business/record/reviewAndRectify.html'
    });
}
var options={
    fullscreenEl:false //关闭全屏按钮
  }

Vue.use(vuePhotoPreview,options)
var vm = new Vue({
    el: '#rrapp',
    data: {

        id:'',
        showList: true,
        title: null,
        firstAddShowFlag: true,
        addFirstKindDetailData: {},
        superviseRecordData:{},
        questionData:{},
        roleId:$("#roleId").val(),
        dqDwId:$("#dqDwId").val(),
        firstKindSubmitForm: {
            levelNum: '1',
            questionDescription: '',
            isGenerateStandardTemplate: '0',
            parentId: '0'
        }
    },
    mounted:function() {
        this.getDataDetail();
        this.getQuestionDetail();
        setTimeout(function(){
            //在IE上不停的闪烁
           vm.$previewRefresh()
        }, 2000);
    },
    methods: {
      getDataDetail: function() {
        //debugger;
        //var id = this.$route.query.id;
        //vm.id:,
        var params = {
                id:$("#id").val()
            }
//    		debugger;
        var url = baseURL;
        url = url +'business/superviserecord/detailInfo';
        $.ajax({
                type: "GET",
                url: url,
                data:params,
                contentType: "application/json",
                success: function (res) {
                    if (res.code === '0') {
//                    	debugger;
                        vm.superviseRecordData = res.superviseRecord;

                    } else {
                        alert(res.msg);
                    }
                }
            });
      },
       TabHandleClick:function(tab) {
         alert(tab.name)
       },
       findQuestionList: function(type) {
             $(".tab-ul li a").removeClass("liSelected");
             $(".tab-ul").find("li:eq("+(type-1)+")").find("a").addClass("liSelected");
         vm.getQuestionDetail(type)
       },
      getQuestionDetail: function(type) {//全部 未整改 无整改 已整改 未审核 已审核
            setTimeout(function(){
                vm.$previewRefresh()
            }, 2000);
        var modifyStatus = '';//整改状态(0：待整改，1：无整改，2：已整改，3：备存无整改，4：备存待整改)
        var checkStatus = ''; //审核状态(0：待审核，1：审核通过，2：审核未通过)
        if (type === 2) {
          modifyStatus = '0';
        } else if (type === 3) {
                modifyStatus = '1';
            }else if (type === 4) {
          modifyStatus = '2';
        } else if (type === 5) {
          checkStatus = '0';
        } else if (type === 6) {
          checkStatus = '1';
        }
        var params = {
          dcRecordId: $("#id").val(),
          modifyStatus: modifyStatus,
          checkStatus: checkStatus
            }
        //debugger;
        var url = baseURL;
        url = url +'business/supervisequestion/questionDetailInfo';
        $.ajax({
                type: "GET",
                url: url,
                data:params,
                contentType: "application/json",
                success: function (res) {
                    if (res.code === '0') {debugger;
                      //debugger;
                        vm.questionData = res.questionList;
                        for (var i=0; i < res.questionList.length; i++) {
                            var imageList = res.questionList[i].imageList;
                            var fkImageList = res.questionList[i].fkImageList;
                            var rootPath = $("#rootPath").val();
                            var videUrl = res.questionList[i].videoImage;
                            if (videUrl != undefined && videUrl != null && videUrl != '') {
                              res.questionList[i].videoImage = rootPath + encodeURI(videUrl);
                            }
                            if (imageList != undefined && imageList != null && imageList != '') {
                               for (var j=0; j<imageList.length; j++) {
                                     var picUrl = imageList[j].picUrl;
                                     imageList[j].picUrl = rootPath + encodeURI(picUrl);
                                 }
                            }

                            if (fkImageList != undefined && fkImageList != null && fkImageList != '') {
                              for (var k=0; k<fkImageList.length; k++) {
                                  var picUrl = fkImageList[k].picUrl;
                                  fkImageList[k].picUrl = rootPath + encodeURI(picUrl);
                              }
                            }
                        }
                        /*$("#contentDetail").css("height",res.questionList.length*480+"px");*/
                    } else {
                        alert(res.msg);
                    }
                }
            });
      },
      //type=1
      checkQuestion:function (type, questionId, recordId, questionModifyId, questionDescription) {
        //var questionId = $("#id").val();
        //var recordId = recordId;
        //var questionModifyId = questionModifyId;
        //debugger;
        var url = '/business/supervise/questionOpen?questionId='+questionId + "&recordId=" +recordId + "&questionModifyId=" +questionModifyId + "&questionDescription=" +questionDescription + "&type=" +type;
            layer.open({
                title : "",
                type : 2,
                fixed: true,
                closeBtn:0,
                shadeClose: true,
                area : [ "580px", "350px" ],
                content : baseURL + encodeURI(url)
            });
      },
      playVideo:function (videoUrl){
          layer.open({
                //title : "新增执行记录",
                type : 2,
                fixed: true,
                shadeClose: true,
                area : [ "600px", "400px" ],
                content : baseURL + '/business/supervise/openVideo?url='+ encodeURI(videoUrl)
            });
      },

      closeWindow: function() {
        parent.location.reload();
      },
        //取消
        cancelFirstAdd: function () {

        },
    }

});